﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace AbetEvaluation
{
    public partial class EvaluationList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (User.Identity.IsAuthenticated)
                {
                    //show the administrative functions if the user is authenticated as an admin.
                    if (User.IsInRole("admin"))
                    {
                        gvOutcomes.Columns[7].Visible = true;
                        gvOutcomes.Columns[8].Visible = true;
                    }
                }
            }
        }

        protected void gvOutcomes_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            lblDebug.Text = e.CommandName.ToString();

            int index;
            switch (e.CommandName)
            {
                case "Take":
                    index = Int32.Parse(e.CommandArgument as String);
                    Response.Redirect("~/TakeOutcome.aspx?id=" + gvOutcomes.DataKeys[index].Value);
                    break;
                case "Edit":
                    index = Int32.Parse(e.CommandArgument as String);
                    Response.Redirect("~/Admin/AddOutcome.aspx?id=" + gvOutcomes.DataKeys[index].Value);
                    break;
                case "Delete":
                    break;
            }
        }
    }
}